using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace LogParser.Collections
{
    public class TeamList
    {

        #region Private Member Variables

        private DA.TeamListModel _model;

        private Hashtable _teamList;

        #endregion

        #region Public Member Variables

        #endregion

        #region Constructor

        public TeamList( )
        {
            Initialize();
        }

        private void Initialize( )
        {
            _model = new LogParser.DA.TeamListModel();
            _teamList = new Hashtable();

            List<GameObjects.Team> teamList = _model.GetTeamsList();

            foreach ( GameObjects.Team tempTeam in teamList )
            {
                _teamList.Add( tempTeam.Name, tempTeam );
            }

        }

        #endregion

        #region Public Properties

        public int Count
        {
            get
            {
                return _teamList.Count;
            }
        }

        #endregion

        #region Private Properties
        #endregion

        #region Public Methods

        public GameObjects.Team GetTeam( string PlayerTeam )
        {
            try
            {
                GameObjects.Team returnTeam = new LogParser.GameObjects.Team();

                returnTeam = ( LogParser.GameObjects.Team ) ( _teamList[ PlayerTeam ] );

                return returnTeam;

            }
            catch
            {
                return new LogParser.GameObjects.Team();
            }
        }


        public GameObjects.Team GetTeam( int teamId )
        {
            try
            {
                
                foreach ( GameObjects.Team tempTeam in _teamList.Values )
                {
                    if ( tempTeam.ID == teamId )
                        return tempTeam;
                }

                GameObjects.Team returnTeam = new LogParser.GameObjects.Team();
                
                return returnTeam;

            }
            catch
            {
                return new LogParser.GameObjects.Team();
            }
        }

        #endregion

        #region Private Methods
        #endregion

    }
}
